var t = require("../../../../@babel/runtime/helpers/createForOfIteratorHelper"), a = getApp();

Page({
    data: {
        language: "",
        uploadUrl: "upload.uploadPic",
        order_pay_id: "",
        imageUrl: "",
        upImgSrc: "",
        status: "",
        order_ids: ""
    },
    onLoad: function(t) {
        t.id && this.setData({
            order_pay_id: t.id
        }), t.status && this.setData({
            status: t.status
        }), t.order_ids && this.setData({
            order_ids: t.order_ids
        }), this.getJson();
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getJson: function() {
        this.setData({
            imageUrl: "",
            upImgSrc: ""
        });
        var t = this, e = "";
        e += a.getNetAddresss("order.mergePay.remittance"), e += "&order_pay_id=" + this.data.order_pay_id, 
        a._getNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                1 == e.result && t.setData({
                    bank_info: e.data.payee_info,
                    amount_info: e.data.amount,
                    pay_info: e.data.pay_sn
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    onRead: function() {
        var t = this, e = wx.getStorageSync("wx_token"), o = wx.getStorageSync("session"), n = a.getNetAddresss(this.data.uploadUrl);
        n += "&3rd_session=" + o, wx.chooseImage({
            count: 1,
            sizeType: [ "original", "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(a) {
                var o = a.tempFilePaths;
                wx.compressImage({
                    src: o[0],
                    quality: 60,
                    success: function(a) {
                        var o = a.tempFilePath;
                        wx.uploadFile({
                            url: n,
                            filePath: o,
                            name: "file",
                            header: {
                                "Content-Type": "multipart/form-data",
                                Cookie: "PHPSESSID=" + e
                            },
                            success: function(a) {
                                var e = JSON.parse(a.data);
                                1 == e.result ? t.setData({
                                    imageUrl: o,
                                    upImgSrc: e.data.img
                                }) : wx.showToast({
                                    icon: "none",
                                    title: e.msg,
                                    duration: 1500
                                });
                            }
                        });
                    },
                    fail: function(t) {},
                    complete: function(t) {}
                });
            }
        });
    },
    confirmEvent: function() {
        if ("" != this.data.upImgSrc) {
            var t = this, e = a.getNetAddresss("remittance.pay");
            e += "&order_pay_id=" + this.data.order_pay_id, e += "&report_url=" + this.data.upImgSrc, 
            a._getNetWork({
                url: e,
                success: function(a) {
                    var e = a.data;
                    1 == e.result && wx.showToast({
                        title: e.msg,
                        icon: "none",
                        duration: 1500,
                        success: function() {
                            setTimeout(function() {
                                wx.navigateTo({
                                    url: "/packageA/member/myOrder_v2/myOrder_v2?status=2&bank_id=" + t.data.order_pay_id
                                });
                            }, 1500);
                        }
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        } else wx.showToast({
            icon: "none",
            title: "请上传付款凭证",
            duration: 1500
        });
    },
    onLine: function() {
        wx.redirectTo({
            url: "/packageD/buy/orderPay/orderPay?status=" + this.data.status + "&order_id=" + this.data.order_ids
        });
    },
    copybtn: function() {
        var a, e = "", o = t(this.data.bank_info);
        try {
            for (o.s(); !(a = o.n()).done; ) {
                var n = a.value;
                e += " ".concat(n.title, ": ").concat(n.text, " ; ");
            }
        } catch (t) {
            o.e(t);
        } finally {
            o.f();
        }
        wx.setClipboardData({
            data: e || ""
        });
    }
});